{% extends 'base.html' %}

{% block title %}Watchlist App{% endblock %}

{% block content %}
<body class="page">
    <h2>
        <img  alt="Avatar" class="avatar" src="{{ url_for('static', filename='images/avatar.png') }}" >
    </h2>
    <nav>
        <ul>
            <li><a href="{{ url_for('watchlist.index') }}">Home</a></li>
            {% if current_user.is_authenticated %}
            <li><a href="{{ url_for('watchlist.settings') }}">Settings</a></li>
            <li><a href="{{ url_for('watchlist.logout') }}">Logout</a></li>
            {% else %}
            <li><a href="{{ url_for('watchlist.login') }}">Login</a></li>
            {% endif %}
        </ul>
    </nav>
        <p>{{ movies|length }} Titles</p>

        <form method="post">
            Name <input type="text" name="title" autocomplete="off" required style="width: 200px;">
            <br>
            Year <input type="text" name="year" autocomplete="off" required style="width: 200px;">
             <br>
            <input class="btn" type="submit" name="submit" value="Add" style="width: 200px;">
        </form>
    
        <ul class="movie-list">
            {% for movie in movies %}
            <li>{{ movie.title }} - {{ movie.year }}
                <span class="float-right">
               
                    <a class="btn" href="{{ url_for('watchlist.edit', movie_id=movie.id) }}">编辑</a> | 
                    <a class="btn" href="{{ url_for('watchlist.delete', movie_id=movie.id) }}">删除</a> | 
                                
                    <a class="imdb" href="https://www.imdb.com/find?q={{ movie.title }}" target="_blank" 
                    title="Find this movie on IMDb">IMDb</a>
                </span>
            </li>
            {% endfor %}
        </ul>
        <img alt="Walking Totoro" class="totoro" 
        src="{{ url_for('static', filename='images/totoro.gif') }}" title="to~to~ro~">
</body>
{% endblock %}


{# 
    原始代码
    {% extends 'base.html' %}

{% block title %}Watchlist App{% endblock %}

{% block content %}
<body class="page">
    <h2>
        <img  alt="Avatar" class="avatar" src="{{ url_for('static', filename='images/avatar.png') }}" >
    </h2>
    <nav>
        <ul>
            <li><a href="{{ url_for('watchlist.index') }}">Home</a></li>
            {% if current_user.is_authenticated %}
            <li><a href="{{ url_for('watchlist.settings') }}">Settings</a></li>
            <li><a href="{{ url_for('watchlist.logout') }}">Logout</a></li>
            {% else %}
            <li><a href="{{ url_for('watchlist.login') }}">Login</a></li>
            {% endif %}
        </ul>
    </nav>
        <p>{{ movies|length }} Titles</p>
        {% if current_user.is_authenticated %}
        <form method="post">
            Name <input type="text" name="title" autocomplete="off" required>
            Year <input type="text" name="year" autocomplete="off" required>
            <input class="btn" type="submit" name="submit" value="Add">
        </form>
        {% endif %}
        <ul class="movie-list">
            {% for movie in movies %}
            <li>{{ movie.title }} - {{ movie.year }}
                <span class="float-right">
                    {% if current_user.is_authenticated %}
                    <a class="btn" href="{{ url_for('watchlist.edit', movie_id=movie.id) }}">Edit</a>
                    <form class="inline-form" method="post" action="{{ url_for('watchlist.delete', movie_id=movie.id) }}">
                        <input class="btn" type="submit" name="delete" value="Delete" onclick="return confirm('Are you sure?')">
                    </form>
                    {% endif %}
                    <a class="imdb" href="https://www.imdb.com/find?q={{ movie.title }}" target="_blank" title="Find this movie on IMDb">IMDb</a>
                </span>
            </li>
            {% endfor %}
        </ul>
        <img alt="Walking Totoro" class="totoro" 
        src="{{ url_for('static', filename='images/totoro.gif') }}" title="to~to~ro~">
</body>
{% endblock %}

#}